package base

import (
	"gitee.com/dayu1985/can_api/controller/app"
	"gitee.com/dayu1985/framework/database/sql"
)

//初始化完成之后的执行项目
var afterInitMysql []func()

func AfterInitOracleFn(fn func()) {
	afterInitMysql = append(afterInitMysql, fn)
}

// 初始化mysql引擎
func initMysql() {
	initServiceMysql()
	//初始化完成之后
	for _, fn := range afterInitMysql {
		fn()
	}
}

//实例化xorm
func initServiceMysql() {
	prefix := app.MustValue("database", "db.prefix", "")
	Serve = &Service{
		Config: Serve.Config,
		Prefix: prefix,
		Engine: sql.DefaultXorm(app.GetConfig()),
	}
}
